var BSTMG = BSTMG || {};
BSTMG.invoiceModel = {
		init: function(){
			var that = this;
			/*发票发票抬头列表*/
			that.invoiceModelListReq();
		},
		invoiceModelListReq: function(){
			var url = "/sysAdmin/invoice/invoiceModelList/search";
			BSTMG.common.hjhPages(url,function(data){
				var invoiceModelList = data.invoiceModelList;
				var $tbody = $("#invoiceModelList tbody");
				var $tr = '';
				if(invoiceModelList.length > 0) {
					for(var i=0;i<invoiceModelList.length;i++){
						var invoiceModel = invoiceModelList[i];
						var userName = invoiceModel.userEmail;
						if(userName==null || userName==''){
							userName = invoiceModel.userTel;
						}
						$tr += '<tr class="odd">';
						$tr += '<td data-id="'+invoiceModel.invoiceModelId+'">'+(i+1)+'</td>';
						$tr += '<td>'+ BSTMG.tools.checkNull(userName)+'</td>';
						$tr += '<td>'+ BSTMG.tools.checkNull(invoiceModel.invoiceTitle)+'</td>';
						$tr += '<td>'+ BSTMG.tools.checkNull(setOpenType(invoiceModel.openType))  + '</td>';
						$tr += '<td>'+ BSTMG.tools.checkNull(setInvoiceType(invoiceModel.invoiceType))+'</td>';
						$tr += '<td>'+ BSTMG.tools.checkNull(toDate(invoiceModel.addTime,"yyyy-MM-dd hh:mm:ss"))+'</td>';
						if(invoiceModel.openType==1 && invoiceModel.invoiceType==1){
							$tr += '<td><a type="button"  class="btn btn-primary" href="/sysAdmin/invoice/invoiceModelDetail/'+invoiceModel.invoiceModelId+'">详情</a></td>';
						}else{
							$tr += '<td><a type="button"  class="btn btn-primary disabled" href="/sysAdmin/invoice/invoiceModelDetail/'+invoiceModel.invoiceModelId+'">详情</a></td>';
						}
						$tr += '</tr>';
					}
					$tbody.html($tr);
				}else {
					var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
					$tbody.html($tr);
				}
			});
		},
}
$(function(){
	BSTMG.invoiceModel.init();
});


//设置开具
function setOpenType(para){
	if (para == "0") {
		return "个人";
	} else if (para == "1") {
		return "企业";
	}
}
//设置发票类型
function setInvoiceType(para){
	if (para == "0") {
		return "增值税普通发票";
	} else if (para == "1") {
		return "增值税专用发票";
	} 
}